<template>
  <div class="pactTable">
    <el-table ref="multipleTable" :data="list" tooltip-effect="dark" style="width: 100%; height: 100%"
      >
      <el-table-column fixed label="合同名称" width="353">
        <template slot-scope="scope">
          <p class="name">{{ scope.row.contractName }}</p>
          <span class="time">发起人：{{ scope.row.promoterEnterpriseName }}({{ scope.row.contractPromoter }})</span>
        </template>
      </el-table-column>
      <el-table-column prop="signTime" label="时间" width="352">
        <!-- <template slot-scope="scope">
          <p class="begin">始</p>
          <p class="time">2023-04-25 09:44:55</p>
        </template> -->
      </el-table-column>
      <el-table-column label="参与人" width="352">
        <template slot-scope="scope">
            <p class="" v-for="item in scope.row.participantsList" :key="item.userId">{{ item.enterpriseName}}({{ item.userName }}) </p>

        </template>
      </el-table-column>
      <el-table-column prop="contractSignState" label="签署状态" width="160"></el-table-column>
      <el-table-column fixed="right" label="操作" width="250">
        <template slot-scope="scope">
          <!--  slot-scope="scope" -->
          <el-button type="text" size="small" @click="handleEdit(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <div class="flexleft padding15" style="justify-content: flex-end;">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="params.pageNo"
        :page-sizes="[10, 20, 50, 100]" :page-size="params.pageSize" layout="total, prev, pager, next, sizes, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
// import Cookies from 'js-cookie'//获取cookies的信息
import { employeesContractList, } from '@/api/opposite'

export default {
  props:["type"],
  name: "pactTable",
  data() {
    return {
      // 相对方企业请求参数
      params: {
        contractFile: "",//联系人公司名称
        contractName: "",//联系人名称
        contractPromoter: "",//联系人电话
        contractSignState: "",//合同id
        insertTime: "",//企业id
        launchTimeEnd: "",//是否有企业
        launchTimeStart: "",//常用联系人id
        participantsName: "",//申请时间
        promoterEnterpriseId: "",//是否认证 0 否 1是
        promoterEnterpriseName: "",//删除标识 0-否 1-是
        signTimeEnd: "",//关键字搜索key
        signTimeStart: "",//联系人类型 0-个人 1-企业
        staffId: "",//用户id//获取cookies中用户id的信息
        staffType: '',
        pageNo: 1,
        pageSize: 10
      },
      list: [],
      total: 0,
    }
  },
  mounted() {
    if(this.type=="companyDetail"){
      this.params.signTimeStart = 1
      this.params.staffType=1
    }else{
      this.params.signTimeStart = 0
      this.params.staffType=0
    }
    console.log(this.type,"9999")
    if (this.$route.query.id) {
      this.params.staffId = this.$route.query.id
    }
    this.$bus.$off('getinfoht')
    this.$bus.$on("getinfoht", data => {
      this.params.contractName= data.contractName
      this.params.participantsName = data.participantsName
      this.params.contractSignState = data.contractSignState
      this.params.launchTimeEnd = data.launchTimeEnd
      this.params.launchTimeStart = data.launchTimeStart
      this.params.signTimeEnd = data.signTimeEnd
      this.params.signTimeStart = data.signTimeStart
      this.getList()
      return false
    })
    this.getList()
  },
  methods: {
    handleEdit(row) {
      console.log(row, "合同信息");
      this.$router.push({ path: "/SignDocument", query: { id: row.contractId } },()=>{})
    },
    getList() {
      this.emtypetxt = '加载中...';
      employeesContractList(this.params).then(res => {
        this.list = res.result.records
        this.total = res.result.total
        if (this.list.length == 0) {
          this.emtypetxt = '暂无数据'
        }
      }).catch(err => {
        console.log("请求失败", err)
      })
    },
    // 跳转个人详情
    handleClick() {
      this.$router.push({ name: 'unitDetail' },()=>{})
    },
    // 删除
    edit() {
      this.$confirm('确定删除刘贞贞？', '删除', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '删除成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },

    handleSizeChange(val) {
      this.params.pagesize = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.params.pageNo = val
      this.getList()
    },

    handleSelectionChange(val) {
      this.multipleSelection = val;
    }
  }
};
</script>

<style lang="scss" scoped>
.pactTable {
  .begin {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    text-align: center;
    line-height: 18px;
    float: left;
    border-radius: 50%;
    background-color: #b5d6f6;
    color: #0975e1;
  }
}
</style>